import React from 'react';
import { Layout, Breadcrumb, Icon, Tag, Button, Table, Checkbox, Input, Select, Form, Pagination, message, TreeSelect ,Radio,Row,Col,Upload,Modal} from 'antd';
import $ from 'jquery';
import './doctorManage.less';
import Config from '../../common/config';
import City from '../../common/city';
import moment from 'moment';
const {TextArea}=Input;
const RadioButton = Radio.Button;
const RadioGroup = Radio.Group;
const FormItem = Form.Item;
const config = new Config();
const Option = Select.Option;
const InputGroup = Input.Group;
const token = sessionStorage.getItem('token');
class DoctorManage1 extends React.Component {
    constructor(props) {
        super(props);
        this.state = {
            attestation:undefined,//认证
            gender:undefined,//性别
            dorRole:undefined,//角色
            deptId:undefined,//科室
            job:undefined,//职称
            province:undefined,//省
            city:undefined,//市
            region:undefined,//区
            regions:[],//区s
            t_citys:[],//市s
            name:'',//姓名
            goodAt:'',//擅长方向
            productlist: [],//全部商品列表
            productcount: 0,//全部商品条数
            dshCount:0,//待审核
            pagesize: 10,// 每页显示的页数
            pageindex: 1,// 当前页
            selectedRows:{},//选择的行
            depList:[],//科室列表
            fileList:[],//图片列表
            fileList1:[],//图片列表
            fileList2:[],//图片列表
            fileList3:[],//图片列表
            isEdit:false,//是否编辑
            selectedRowKeys:[],
            isEditDoc:true,//修改
        }
    }
    componentDidMount() {
        console.log(this.props.location.state);
        this.GetProguctList();
    }
    //商品列表
    GetProguctList(status) {
        let {gender, dorRole, deptId, job, province, city,  name, goodAt, pagesize,pageindex,attestation,region}=this.state;
        $.ajax({
            url: `${config.integratedBack2}/inte/findDoctorList`,
            type: "POST",
            headers: {
                'Authorization': 'Bearer ' + token,
            },
            data: {
                gender,
                dorRole,
                deptId,
                job,
                province,
                city,
                region,
                name,
                goodAt,
                attestation,
                pagesize,
                pageindex,
            },
            success: res => {
                if (res.code === 200) {
                    res.result.forEach((item, index) => {
                        item.key = index + 1;
                        if(status){
                            if(item.id===this.state.selectedRows.id){
                                this.setState({
                                    selectedRows:item,
                                })
                            }
                        }
                    });
                    this.setState({
                        productlist: res.result,
                        productcount: res.pageCounts?res.pageCounts:0,
                        depList:res.depList,
                        dshCount: res.dshCount?res.dshCount:0,
                    })
                }else{
                    message.info(res.msg,1);
                    this.setState({
                        productlist: [],
                        productcount: 0,
                        depList:[],
                    });
                }
            },
            error:err=>{
                console.log(err);
            }
        });
    }
    //搜索
    SearchProductListBtn() {
        const form = this.props.form;
        this.setState({
            name: form.getFieldValue('name1') ? form.getFieldValue('name1') : '',
            goodAt: form.getFieldValue('goodAt1') ? form.getFieldValue('goodAt1') : '',
            selectedRowKeys:[],
            selectedRows:{},
        }, () => {
            this.GetProguctList();
        });
    }
    //重置
    ResetBtn() {
        const form = this.props.form;
        form.resetFields();
        this.setState({
            pageindex: 1,
            gender:undefined,//性别
            attestation:undefined,//认证
            dorRole:undefined,//角色
            deptId:undefined,//科室
            job:undefined,//职称
            region:undefined,
            province:undefined,//省
            city:undefined,//市
            name1:'',//姓名
            goodAt1:'',//擅长方向
            selectedRowKeys:[],
            selectedRows:{},
        }, () => {
            this.GetProguctList();
        });
    }
    // 分页
    changePage(pageindex) {
        this.setState({
            pageindex,
            selectedRowKeys:[],
            selectedRows:{},
        }, () => {
            this.GetProguctList();
        });
    }
    //筛选
    handleValueChange(status,value){
        console.log(City);
        let data={};
        if(status===1){
            data.gender=value;
        }else if(status===2){
            data.dorRole=value;
            this.setState({
                job:undefined
            })
        }else if(status===3){
            data.deptId=value;
        }else if(status===4){
            data.job=value;
        }else if(status===5){
            data.province=value;
            City.forEach(item=>{
                if(item.name===value){
                    this.setState({
                        t_citys:item.child,
                        city:undefined,
                        region:undefined,
                    })
                }
            })
        }else if(status===6){
            data.city=value;
            this.state.t_citys.forEach(item=>{
                if(item.name===value){
                    this.setState({
                        regions:item.child?item.child:[],
                        region:undefined,
                    })
                }
            })
        }else if(status===8){
            data.region=value;
        }else if(status===7){
            data.attestation=value;
        }
        this.setState(data);
    }

    //限制用户必须上传图片格式的文件、图片大小
    beforeUpload(file, fileList) {
        let isIMG = file.type.indexOf('image') != -1;
        if (!isIMG) {
            message.config({ top: 50 });
            message.error('您只能上传图片！');
        }
        let isLt5M = file.size / 1024 / 1024 < 5;
        if (!isLt5M) {
            message.config({ top: 50 });
            message.error('您上传的图片大小必须小于5MB！');
        }
        return isIMG && isLt5M;
    }
    //预览图片对话框
    previewImg(file) {
        this.setState({
            previewImage: file.url || file.thumbUrl,
            previewVisible: true,
        });
    }
    previewImg1(file) {
        this.setState({
            previewImage: file.url || file.thumbUrl,
            previewVisible1: true,
        });
    }
    previewImg2(file) {
        this.setState({
            previewImage: file.url || file.thumbUrl,
            previewVisible2: true,
        });
    }
    previewImg3(file) {
        this.setState({
            previewImage: file.url || file.thumbUrl,
            previewVisible3: true,
        });
    }
    //上传图片
    normFile(e) {
        this.setState({
            fileList: e.fileList
        });
        if (Array.isArray(e)) {
            return e;
        }
        return e && e.fileList;
    }
    //上传图片
    normFile1(e) {
        console.log(e.fileList);
        this.setState({
            fileList1: e.fileList
        });
        if (Array.isArray(e)) {
            return e;
        }
        return e && e.fileList;
    }
    //上传图片
    normFile2(e) {
        this.setState({
            fileList2: e.fileList
        },()=>{
        });
        if (Array.isArray(e)) {
            return e;
        }
        return e && e.fileList;
    }
    //上传图片
    normFile3(e) {
        this.setState({
            fileList3: e.fileList
        });
        if (Array.isArray(e)) {
            return e;
        }
        return e && e.fileList;
    }
    //关闭预览图片对话框
    cancelPreview() {
        this.setState({ previewVisible: false })
    }
    cancelPreview1() {
        this.setState({ previewVisible1: false })
    }
    cancelPreview2() {
        this.setState({ previewVisible2: false })
    }
    cancelPreview3() {
        this.setState({ previewVisible3: false })
    }
    //是否编辑
    handleEditChange(){
        let {selectedRows}=this.state;
        let isEdit=this.state.isEdit;
        if(isEdit){
            this.props.form.validateFields((err,values)=>{
                if(err){
                    return;
                }
                console.log(values);
                if(values.Filedata.length!==2){
                    message.error('必须上传正反2张身份证照片',1);
                    return;
                }
                let imgURL3=[];
                if(values.Filedata3){
                    values.Filedata3.forEach(item=>{
                        imgURL3.push(item.response ? item.response.data : item.data,);
                    })
                }
                $.ajax({
                    url: `${config.integratedBack2}/inte/editDoctors`,
                    type: "POST",
                    headers: {
                        'Authorization': 'Bearer ' + token,
                    },
                    data: {
                        id:this.state.selectedRows.id,
                        name:values.name,
                        dorRole:values.dorRole,
                        job:values.job,
                        deptId:values.deptId,
                        idNumber:values.idNumber,
                        desc:values.desc,
                        goodAt:values.goodAt,
                        attestation:values.attestation,
                        zmPhotograph:values.Filedata[0].response ? values.Filedata[0].response.data : values.Filedata[0].data,
                        fmPhotograph:values.Filedata[1].response ? values.Filedata[1].response.data : values.Filedata[1].data,
                        xkzPhotograph:values.Filedata1[0].response ? values.Filedata1[0].response.data : values.Filedata1[0].data,
                        xkzscPhotograph:values.Filedata2[0].response ? values.Filedata2[0].response.data : values.Filedata2[0].data,
                        qtCertificate:imgURL3.join('&'),
                    },
                    success: res => {
                        if (res.code === 200) {
                            message.info('修改成功！',1);
                            this.setState({
                                isEdit:!isEdit,
                            },()=>{
                                this.GetProguctList(true);
                            })
                        }else{
                            message.info(res.msg,1);
                        }
                    },
                    error:err=>{
                        console.log(err);
                    }
                });
            })
        }else{
            this.setState({
                isEdit:!isEdit,
                fileList:[],
                fileList1:[],
                fileList2:[],
                fileList3:[],
            },()=>{
                if(this.state.isEdit){
                    let {fileList,fileList1,fileList2,fileList3}=this.state;
                    if(selectedRows.zmPhotograph){
                        fileList[0] = {
                            uid: 1,
                            name: 'a',//随便写的
                            status: 'done',
                            url: selectedRows.zmPhotograph,
                            data: selectedRows.zmPhotograph
                        };
                        fileList[1] = {
                            uid: 2,
                            name: 'b',//随便写的
                            status: 'done',
                            url: selectedRows.fmPhotograph,
                            data: selectedRows.fmPhotograph
                        };
                        fileList1[0] = {
                            uid: -1,
                            name: 'a',//随便写的
                            status: 'done',
                            url: selectedRows.xkzPhotograph,
                            data: selectedRows.xkzPhotograph,
                        };
                        fileList2[0] = {
                            uid: -1,
                            name: 'a',//随便写的
                            status: 'done',
                            url: selectedRows.xkzscPhotograph,
                            data: selectedRows.xkzscPhotograph
                        };
                    }
                    if(selectedRows.qtCertificate){
                        (selectedRows.qtCertificate.split('&')).forEach((item,i)=>{
                            fileList3.push({
                                uid: i+1,
                                name: 'a'+i,//随便写的
                                status: 'done',
                                url: item,
                                data: item
                            })
                        })
                    }
                    this.setState({
                        isEditDoc:selectedRows.dorRole==="医生"?true:false,
                    });
                    this.props.form.setFieldsValue({
                        name:selectedRows.name,
                        dorRole:selectedRows.dorRole,
                        job:selectedRows.job,
                        deptId:(selectedRows.deptId).toString(),
                        attestation:selectedRows.attestation,
                        idNumber:selectedRows.idNumber,
                        goodAt:selectedRows.goodAt,
                        desc:selectedRows.desc,
                        Filedata:(selectedRows.zmPhotograph)?fileList:undefined,
                        Filedata1:(selectedRows.xkzPhotograph)?fileList1:undefined,
                        Filedata2:(selectedRows.xkzscPhotograph)?fileList2:undefined,
                        Filedata3:selectedRows.qtCertificate?fileList3:undefined,
                    })
                }
            })
        }
    }
    //是否通过
    handlePassed(state){
        console.log(state);
        $.ajax({
            url: `${config.integratedBack1}/inte/attStting`,
            type: "GET",
            headers: {
                'Authorization': 'Bearer ' + token,
            },
            data: {
                id:this.state.selectedRows.id,
                attestation:state,
            },
            success: res => {
                if (res.code === 200) {
                    this.GetProguctList(true);
                }else{
                    message.info(res.msg,1);
                }
            },
            error:err=>{
                console.log(err);
            }
        });
    }
    handleEditRole(value){
        this.setState({
            isEditDoc:value=="医生"?true:false,
        })
    }
    //改变状态
    changeState(record,state){
        let url =`${config.integratedBack2}/inte/statusStting`;
        $.ajax({
            url:url,
            type: "GET",
            async: true,
            headers: { Authorization: 'Bearer '+sessionStorage.getItem('token')},
            data:{
                id:record.id,
                onstate:state,
            },
            success:data=>{
                console.log(data);
                if(data.code===200){
                    this.GetProguctList();
                    message.success('修改成功！',1);
                }else{
                    message.info(data.msg,1);
                }
            },
            error:err=>{
                console.log(err);
            }
        });
    }
    //行选中
    render() {
        const { getFieldDecorator } = this.props.form;
        const formItemLayout = { labelCol: { span: 6 }, wrapperCol: { span: 18 } };
        const formItemLayout1 = { labelCol: { span: 3 }, wrapperCol: { span: 18 } };
        let {selectedRows,isEdit,dshCount,selectedRowKeys}=this.state;
        const rowSelection = {
            type:"radio",
            selectedRowKeys,
            onChange: (selectedRowKeys, selectedRows) => {
                this.setState({
                    selectedRows:selectedRows[0],
                    selectedRowKeys,
                },()=>{
                    console.log(this.state.selectedRows);
                });
            }
        };
        const columns = [
            {
                title: '序号',
                dataIndex: 'key',
            },
            {
                title: '医生ID',
                dataIndex: 'id',
            },
            {
                title: '手机',
                dataIndex: 'phone',
            },
            {
                title: '姓名',
                dataIndex: 'name',
            },
            {
                title: '角色',
                dataIndex: 'dorRole',
            },
            {
                title: '职称',
                dataIndex: 'job',
            },
            {
                title: '性别',
                dataIndex: 'gender',
                render:text=><span>{text==1?'男':text==2?'女':'不详'}</span>
            },
            {
                title: '科室',
                dataIndex: 'depName',
            },
            {
                title: '出生日期',
                dataIndex: 'birthday',
            },
            {
                title: '擅长方向',
                dataIndex: 'goodAt',
                render:text=><span>{text?text.slice(0,10)+'...':''}</span>
            }
            ,
            {
                title: '省',
                dataIndex: 'province',
            },
            {
                title: '市',
                dataIndex: 'city',
            },
            {
                title: '区',
                dataIndex: 'region',
            },
            {
                title: '来源',
                dataIndex: 'source',
            },
            {
                title: '认证',
                dataIndex: 'attestation',
                render:text=><span style={{color:text==0?'#1a91d1':text==1?'#f18914':text==3?'#469946':text==2?'#d83a35':''}}>{text==0?'未认证':text==1?'申请中':text==3?'已认证':text==2?'未通过':''}</span>
            },
            {
                title: '状态',
                dataIndex: 'onstate',
                render: (text, record) => {
                    if (text ==1) {
                        return  <Button type="danger" onClick={() => this.changeState(record,0)}>禁用</Button>
                    } else if (text ==0) {
                        return <Button style={{background:'rgb(60,172,208)',color:'#fff'}} onClick={() => this.changeState(record,1)}>正常</Button>
                    }
                },
            },
            {
                title: '注册时间',
                dataIndex: 'createdAt',
                render:text=><span>{text?moment(text).format('YYYY-MM-DD HH:mm:ss'):''}</span>
            },
            {
                title: '最后登录时间',
                dataIndex: 't_endtime',
            },
        ];
        return (
            <Form>
                <div className='goods-label' style={{ minWidth: 1250 }}>
                    <div className='goods-label-cont clearfix'>
                        <div className='goods-label-cont-nav clearfix'>
                            <Breadcrumb separator=">">
                                <Breadcrumb.Item>综合平台</Breadcrumb.Item>
                                <Breadcrumb.Item><span className='separator-a'>医生管理</span></Breadcrumb.Item>
                            </Breadcrumb>
                            <span style={{float:'right',color:'red'}}>待审核（{dshCount}）</span>
                        </div>
                        <div className='member-content-Search clearfix'>
                            <div className='addetd'>
                                <FormItem>
                                    {getFieldDecorator('name1')(
                                        <Input className='addetd-a-r' addonBefore="医生姓名" placeholder="请输入" />
                                    )
                                    }
                                </FormItem>
                            </div>
                            <div className='addetd addetd-a indtner'>
                                <InputGroup compact>
                                    <Input addonBefore="性 别" />
                                    <Select placeholder='请选择' value={this.state.gender} onChange={this.handleValueChange.bind(this,1)}>
                                        <Option value="">全部</Option>
                                        <Option value="1">男</Option>
                                        <Option value="2">女</Option>
                                        <Option value="0">未知</Option>
                                    </Select>
                                </InputGroup>
                            </div>
                            <div className='addetd addetd-a indtner'>
                                <InputGroup compact>
                                    <Input addonBefore="角 色" />
                                    <Select placeholder='请选择' value={this.state.dorRole} onChange={this.handleValueChange.bind(this,2)}>
                                        <Option value="">全部</Option>
                                        <Option value="医生">医生</Option>
                                        <Option value="药师">药师</Option>
                                    </Select>
                                </InputGroup>
                            </div>
                            <div className='addetd addetd-a indtner'>
                                <InputGroup compact>
                                    <Input addonBefore="科 室" />
                                    <Select placeholder='请选择' value={this.state.deptId} onChange={this.handleValueChange.bind(this,3)}>
                                        <Option value="">全部</Option>
                                        {this.state.depList.map(item=><Option value={(item.id).toString()} key={item.id}>{item.name}</Option>)}
                                    </Select>
                                </InputGroup>
                            </div>
                            <div className='addetd addetd-a indtner'>
                                <InputGroup compact>
                                    <Input addonBefore="职 称" />
                                    <Select placeholder='请选择'  value={this.state.job} onChange={this.handleValueChange.bind(this,4)} >
                                        <Option value="">全部</Option>
                                        {this.state.dorRole?
                                            (this.state.dorRole==="医生"?
                                                ["医师" ,"主治医师","副主任医师","主任医师"].map(item=> <Option value={item} key={item}>{item}</Option>)
                                                :["药士","药师","主管药师","副主任药师","主任药师"].map(item=> <Option value={item} key={item}>{item}</Option>)):''}
                                    </Select>
                                </InputGroup>
                            </div>
                        </div>
                        <div className='member-content-Search clearfix'>
                            <div className='addetd'>
                                <FormItem>
                                    {
                                        getFieldDecorator('goodAt1')(
                                            <Input className='addetd-a-r' addonBefore="擅长方向" placeholder="请输入" />
                                        )
                                    }
                                </FormItem>
                            </div>
                            <div className='addetd addetd-a indtner'>
                                <InputGroup compact>
                                    <Input addonBefore="选 省" />
                                    <Select value={this.state.province} onChange={this.handleValueChange.bind(this,5)} placeholder='请选择'>
                                        <Option value="">全部</Option>
                                        {City.map(item=> <Option value={item.name} key={item.code}>{item.name}</Option>)}
                                    </Select>
                                </InputGroup>
                            </div>
                            <div className='addetd addetd-a indtner'>
                                <InputGroup compact>
                                    <Input addonBefore="选 市" />
                                    <Select value={this.state.city} onChange={this.handleValueChange.bind(this,6)} placeholder='请选择'>
                                        <Option value="">全部</Option>
                                        {this.state.t_citys.map(item=> <Option value={item.name} key={item.code}>{item.name}</Option>)}
                                    </Select>
                                </InputGroup>
                            </div>
                            <div className='addetd addetd-a indtner'>
                                <InputGroup compact>
                                    <Input addonBefore="选 区" />
                                    <Select value={this.state.region} onChange={this.handleValueChange.bind(this,8)} placeholder='请选择'>
                                        <Option value="">全部</Option>
                                        {this.state.regions.map(item=> <Option value={item.name} key={item.code}>{item.name}</Option>)}
                                    </Select>
                                </InputGroup>
                            </div>
                            <div className='addetd addetd-a indtner'>
                                <InputGroup compact>
                                    <Input addonBefore="认 证" />
                                    <Select value={this.state.attestation} onChange={this.handleValueChange.bind(this,7)} placeholder='请选择'>
                                        <Option value="">全部</Option>
                                        <Option value="0">未认证</Option>
                                        <Option value="1">申请中</Option>
                                        <Option value="2">未通过</Option>
                                        <Option value="3">已认证</Option>
                                    </Select>
                                </InputGroup>
                            </div>
                            <Button type="primary" className='member-button' icon="search" onClick={this.SearchProductListBtn.bind(this)}>搜索</Button>
                            <Button type="primary" className='member-button' icon="reload" onClick={this.ResetBtn.bind(this)}>重置</Button>
                        </div>
                        <div className='clearfix'>
                            <Table rowSelection={rowSelection}
                                   rowKey="key"
                                   columns={columns}
                                   dataSource={this.state.productlist}
                                   pagination={false}
                                   bordered
                                   className='allgoods-table'
                            />
                        </div>
                        <div className='goods-label-let'>
                            <div className="floor-ppagi">
                                {
                                    this.state.productcount == 0 ?
                                        <p className="floor-ppagip">
                                            共{this.state.productcount}条记录
                                        </p> :
                                        <p className="floor-ppagip">
                                            当前显示
                                            {this.state.pagesize * (this.state.pageindex - 1) + 1}—
                                            {this.state.pagesize * this.state.pageindex < this.state.productcount ? this.state.pagesize * this.state.pageindex : this.state.productcount}条记录，
                                            共{this.state.productcount}条记录
                                        </p>
                                }
                                <Pagination current={this.state.pageindex} total={this.state.productcount || 1} defaultPageSize={this.state.pagesize} onChange={this.changePage.bind(this)} />
                            </div>
                        </div>
                        <div>
                            <RadioGroup defaultValue="a">
                                <RadioButton value="a">认证信息</RadioButton>
                            </RadioGroup>
                            { selectedRows.id?(isEdit?
                                <div style={{display:'inline-block'}}>
                                    <Button style={{marginLeft:'40px'}} type="primary" onClick={this.handleEditChange.bind(this)}>保存</Button>
                                    <Button style={{marginLeft:'40px'}} type="danger" onClick={()=>{this.setState({isEdit:false})}}>取消</Button>
                                </div> :
                                <Button style={{marginLeft:'40px'}} type="primary" onClick={this.handleEditChange.bind(this)}>编辑</Button>):''}
                        </div>
                        { selectedRows.id?(!isEdit?<div  className="business-back-doc-info">
                            <Row>
                                <Col span={7} offset={1}>
                                    姓名：{selectedRows.name}
                                </Col>
                                <Col span={7} offset={1}>
                                    角色：{selectedRows.dorRole}
                                </Col>
                            </Row>
                            <Row>
                                <Col span={7} offset={1}>
                                    职称：{selectedRows.job}
                                </Col>
                                <Col span={7} offset={1}>
                                    科室：{selectedRows.depName}
                                </Col>
                            </Row>
                            <Row>
                                <Col span={7} offset={1}>
                                    认证：{selectedRows.attestation==0?'未认证':selectedRows.attestation==1?'申请中':selectedRows.attestation==3?'已认证':'未通过'}
                                </Col>
                                <Col span={7} offset={1}>
                                    身份证号：{selectedRows.idNumber}
                                </Col>
                            </Row>
                            <Row>
                                <Col span={20} offset={1} >
                                    <div className="doctor-good-at">
                                        <p className="p1">擅长方向：</p>
                                        <p className="p2">{selectedRows.goodAt}</p>
                                    </div>
                                </Col>
                            </Row>
                            <Row>
                                <Col span={20} offset={1} >
                                    <div className="doctor-good-at">
                                        <p className="p1">简  介：</p>
                                        <p className="p2">{selectedRows.desc}</p>
                                    </div>
                                </Col>
                            </Row>
                            <Row>
                                <Col span={23} offset={1}>
                                    <p>身份证照片：</p>
                                    {selectedRows.zmPhotograph?<a href={selectedRows.zmPhotograph} target="_blank"  style={{marginRight:'20px'}}>
                                        <img src={selectedRows.zmPhotograph} style={{ height: "100px", width: "200px" }} />
                                    </a>:'未上传照片'}
                                    {selectedRows.fmPhotograph?<a href={selectedRows.zmPhotograph} target="_blank"  style={{marginRight:'20px'}}>
                                        <img src={selectedRows.fmPhotograph} style={{ height: "100px", width: "200px" }} />
                                    </a>:''}
                                </Col>
                            </Row>
                            <Row>
                                <Col span={23} offset={1}>
                                    <p>职业资格证书：</p>
                                    {selectedRows.xkzPhotograph?<a href={selectedRows.xkzPhotograph} target="_blank"  style={{marginRight:'20px'}}>
                                        <img src={selectedRows.xkzPhotograph } style={{ height: "100px", width: "200px" }} />
                                    </a>:'未上传照片'}
                                </Col>
                            </Row>
                            <Row>
                                <Col span={23} offset={1}>
                                    <p>手持职业资格证书：</p>
                                    {selectedRows.xkzscPhotograph?<a href={selectedRows.xkzscPhotograph} target="_blank" style={{marginRight:'20px'}}>
                                        <img src={selectedRows.xkzscPhotograph} style={{ height: "100px", width: "200px" }} />
                                    </a>:'未上传照片'}
                                </Col>
                            </Row>
                            <Row>
                                <Col span={23} offset={1}>
                                    <p>其他证书：</p>
                                    {selectedRows.qtCertificate?(selectedRows.qtCertificate.split('&')).map((item,i)=>{
                                            return <a href={item} target="_blank" key={i} style={{marginRight:'20px'}}>
                                                <img src={item} style={{ height: "100px", width: "200px" }} />
                                            </a>
                                        }):'未上传图片'
                                    }
                                </Col>
                            </Row>
                            <Row>
                                <Col span={7} offset={1}>
                                </Col>
                                {selectedRows.attestation==1?<Col span={7} offset={1}>
                                    <Button onClick={this.handlePassed.bind(this,3)}>通过</Button>
                                    <Button type="danger" style={{marginLeft:'10px'}} onClick={this.handlePassed.bind(this,2)}>否决</Button>
                                </Col>:''}
                                {selectedRows.attestation==3?<Col span={7} offset={1}>
                                    <Button type="danger" onClick={this.handlePassed.bind(this,2)}>取消认证</Button>
                                </Col>:''}
                            </Row>
                        </div>:<div  className="business-back-doc-info">
                            <Row>
                                <Col span={7} offset={1}>
                                    <FormItem {...formItemLayout} label="姓名"  >
                                        {getFieldDecorator('name', {
                                            rules: [
                                                { required: true, message: '姓名不能为空' },
                                                { max: 20, message: '姓名不能超过20个字' },
                                            ],
                                        })(
                                            <Input placeholder="请输入姓名"  />
                                        )}
                                    </FormItem>
                                </Col>
                                <Col span={7} offset={1}>
                                    <FormItem {...formItemLayout} label="角色"  >
                                        {getFieldDecorator('dorRole', {
                                            rules: [
                                                { required: true, message: '角色不能为空' },
                                            ],
                                        })(
                                            <Select placeholder='请选择' onChange={this.handleEditRole.bind(this)}>
                                                <Option value="医生">医生</Option>
                                                <Option value="药师">药师</Option>
                                            </Select>
                                        )}
                                    </FormItem>
                                </Col>
                            </Row>
                            <Row>
                                <Col span={7} offset={1}>
                                    <FormItem {...formItemLayout} label="职称"  >
                                        {getFieldDecorator('job', {
                                            rules: [
                                                { required: true, message: '职称不能为空' },
                                            ],
                                        })(
                                            <Select placeholder='请选择'>
                                                {this.state.isEditDoc?
                                                        ["医师" ,"主治医师","副主任医师","主任医师"].map(item=> <Option value={item} key={item}>{item}</Option>)
                                                        :["药士","药师","主管药师","副主任药师","主任药师"].map(item=> <Option value={item} key={item}>{item}</Option>)}
                                            </Select>
                                        )}
                                    </FormItem>
                                </Col>
                                <Col span={7} offset={1}>
                                    <FormItem {...formItemLayout} label="科室"  >
                                        {getFieldDecorator('deptId', {
                                            rules: [
                                                { required: true, message: '科室不能为空' },
                                            ],
                                        })(
                                            <Select placeholder='请选择'>
                                                {this.state.depList.map(item=><Option value={(item.id).toString()} key={item.id}>{item.name}</Option>)}
                                            </Select>
                                        )}
                                    </FormItem>
                                </Col>
                            </Row>
                            <Row>
                                <Col span={7} offset={1}>
                                    <FormItem {...formItemLayout} label="认证"  >
                                        {getFieldDecorator('attestation', {
                                            rules: [
                                                { required: true, message: '认证不能为空' },
                                            ],
                                        })(
                                            <Select placeholder='请选择'>
                                                <Option value="0">未认证</Option>
                                                <Option value="1">申请中</Option>
                                                <Option value="2">未通过</Option>
                                                <Option value="3">已认证</Option>
                                            </Select>
                                        )}
                                    </FormItem>
                                </Col>
                                <Col span={7} offset={1}>
                                    <FormItem {...formItemLayout} label="身份证号"  >
                                        {getFieldDecorator('idNumber', {
                                            rules: [
                                                { required: true, message: '身份证号不能为空' },
                                                {  pattern: /^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}([0-9]|X|x)$/, message: '请输入18位身份证号' }
                                            ],
                                        })(
                                            <Input placeholder="请输入身份证号"/>
                                        )}
                                    </FormItem>
                                </Col>
                            </Row>
                            <Row>
                                <Col span={20} offset={1} >
                                    <div className="doctor-good-at">
                                        <p className="p1"><span style={{color:'red'}}>*</span>擅长方向：</p>
                                        <p className="p2" >
                                            {getFieldDecorator('goodAt', {
                                                rules: [
                                                    { required: true, message: '擅长方向不能为空' },
                                                    { max: 1000, message: '擅长方向不能超过1000个字' },
                                                ],
                                            })(
                                                <TextArea placeholder="请输入擅长方向" autosize={{ minRows: 2, maxRows: 6 }} />
                                            )}
                                        </p>
                                    </div>
                                </Col>
                            </Row>
                            <Row>
                                <Col span={20} offset={1} >
                                    <div className="doctor-good-at">
                                        <p className="p1"><span style={{color:'red'}}>*</span>简介：</p>
                                        <p className="p2">
                                            {getFieldDecorator('desc', {
                                                rules: [
                                                    { required: true, message: '简介不能为空' },
                                                    { max: 1000, message: '简介不能超过1000个字' },
                                                ],
                                            })(
                                                <TextArea placeholder="请输入简介" autosize={{ minRows: 2, maxRows: 6 }} />
                                            )}
                                        </p>
                                    </div>
                                </Col>
                            </Row>
                            <Row>
                                <Col span={23} offset={1}>
                                    <FormItem label='身份证照片(正反两张)'{...formItemLayout1} >
                                        {getFieldDecorator('Filedata', {
                                            valuePropName: 'fileList', getValueFromEvent: this.normFile.bind(this),
                                            rules: [
                                                { required: true, message: '必须上传身份证照片' },
                                            ],
                                        })(
                                            <Upload
                                                accept="image/*"
                                                name="img"
                                                action={config.integratedBack1 + "/bannerImg"}
                                                beforeUpload={this.beforeUpload.bind(this)}
                                                listType="picture-card"
                                                className="upload-list-inline"
                                                onPreview={this.previewImg.bind(this)}
                                            >
                                                {
                                                    this.state.fileList.length >= 2 ? null :
                                                        <div >
                                                            <Icon type="plus" />
                                                            <div className="ant-upload-text">点击上传照片</div>
                                                        </div>
                                                }
                                            </Upload>
                                        )}
                                    </FormItem>
                                    {/* 预览图片对话框 */}
                                    <Modal visible={this.state.previewVisible} footer={null} onCancel={this.cancelPreview.bind(this)}>
                                        <img alt="example" style={{ width: '100%' }} src={this.state.previewImage} />
                                    </Modal>
                                </Col>
                            </Row>
                            <Row>
                                <Col span={23} offset={1}>
                                    <FormItem label='职业资格证书'{...formItemLayout1} >
                                        {getFieldDecorator('Filedata1', {
                                            valuePropName: 'fileList', getValueFromEvent: this.normFile1.bind(this),
                                            rules: [
                                                { required: true, message: '必须上传手持身份证照片' },
                                            ],
                                        })(
                                            <Upload
                                                accept="image/*"
                                                name="img"
                                                action={config.integratedBack1 + "/bannerImg"}
                                                beforeUpload={this.beforeUpload.bind(this)}
                                                listType="picture-card"
                                                className="upload-list-inline"
                                                onPreview={this.previewImg1.bind(this)}
                                            >
                                                {
                                                    this.state.fileList1.length >= 1 ? null :
                                                        <div >
                                                            <Icon type="plus" />
                                                            <div className="ant-upload-text">点击上传照片</div>
                                                        </div>
                                                }
                                            </Upload>
                                        )}
                                    </FormItem>
                                    {/* 预览图片对话框 */}
                                    <Modal visible={this.state.previewVisible1} footer={null} onCancel={this.cancelPreview1.bind(this)}>
                                        <img alt="example" style={{ width: '100%' }} src={this.state.previewImage} />
                                    </Modal>
                                </Col>
                            </Row>
                            <Row>
                                <Col span={23} offset={1}>
                                    <FormItem label='手持职业资格证书'{...formItemLayout1} >
                                        {getFieldDecorator('Filedata2', {
                                            valuePropName: 'fileList', getValueFromEvent: this.normFile2.bind(this),
                                            rules: [
                                                { required: true, message: '必须上传职业资格证书' },
                                            ],
                                        })(
                                            <Upload
                                                accept="image/*"
                                                name="img"
                                                action={config.integratedBack1 + "/bannerImg"}
                                                beforeUpload={this.beforeUpload.bind(this)}
                                                listType="picture-card"
                                                className="upload-list-inline"
                                                onPreview={this.previewImg2.bind(this)}
                                            >
                                                {
                                                    this.state.fileList2.length >= 1 ? null :
                                                        <div >
                                                            <Icon type="plus" />
                                                            <div className="ant-upload-text">点击上传照片</div>
                                                        </div>
                                                }
                                            </Upload>
                                        )}
                                    </FormItem>
                                    {/* 预览图片对话框 */}
                                    <Modal visible={this.state.previewVisible2} footer={null} onCancel={this.cancelPreview2.bind(this)}>
                                        <img alt="example" style={{ width: '100%' }} src={this.state.previewImage} />
                                    </Modal>
                                </Col>
                            </Row>
                            <Row>
                                <Col span={23} offset={1}>
                                    <FormItem label='其他证书'{...formItemLayout1} >
                                        {getFieldDecorator('Filedata3', {
                                            valuePropName: 'fileList', getValueFromEvent: this.normFile3.bind(this),
                                        })(
                                            <Upload
                                                accept="image/*"
                                                name="img"
                                                action={config.integratedBack1 + "/bannerImg"}
                                                beforeUpload={this.beforeUpload.bind(this)}
                                                listType="picture-card"
                                                className="upload-list-inline"
                                                onPreview={this.previewImg3.bind(this)}
                                            >

                                                <div >
                                                    <Icon type="plus" />
                                                    <div className="ant-upload-text">点击上传照片</div>
                                                </div>

                                            </Upload>
                                        )}
                                    </FormItem>
                                    {/* 预览图片对话框 */}
                                    <Modal visible={this.state.previewVisible3} footer={null} onCancel={this.cancelPreview3.bind(this)}>
                                        <img alt="example" style={{ width: '100%' }} src={this.state.previewImage} />
                                    </Modal>
                                </Col>
                            </Row>
                        </div>):''}
                    </div>
                </div>
            </Form>
        )
    }
}

const BusinessBackDoctorManage = Form.create()(DoctorManage1);
export default BusinessBackDoctorManage;